home *** CD-ROM | disk | FTP | other *** search
- #include "MacIncludes.h"
- #include "hlp.h"
- #include "help.h"
- #include "utl.h"
- #include "Rk.h"
-
- /*______________________________________________________________________
-
- Global Variables.
- _____________________________________________________________________*/
-
-
- WindowPtr HelpWindow = nil; /* ptr to help window */
- static WindowRecord HelpWRecord; /* help window record */
- static WindowObject HelpWindObject; /* help window object */
- static rpp_PrtBlock helpPrint; /* help window print block */
- static Boolean MenuPick=true; /* true if command was via menu pick */
-
-
- /*______________________________________________________________________
-
- Click - Process Mouse Down Event.
-
- Entry: where = mouse down location, local coords.
- modifiers = modifier keys.
- _____________________________________________________________________*/
-
- static void Click (Point where, short modifiers)
-
- {
- #pragma unused (modifiers)
-
- hlp_Click(where);
- }
-
- /*______________________________________________________________________
-
- Help - Process Mouse Down Event in Help Mode.
-
- Entry: where = mouse down location, local coords.
- _____________________________________________________________________*/
-
-
- static void Help (Point where)
-
- {
- Rect tcRect; /* tcon rectangle */
-
- hlp_GetTconRect(&tcRect);
- tcRect.top -= 15;
- help_Open(PtInRect(where, &tcRect) ? tagHelpTcon : tagHelpWind);
- }
-
- /*______________________________________________________________________
-
- Close - Close Window.
- _____________________________________________________________________*/
-
-
- static void Close (void)
-
- {
- hlp_Close();
- CloseWindow(HelpWindow);
- HelpWindow = nil;
- }
-
- /*______________________________________________________________________
-
- Save - Process Save Command.
-
- Exit: function result = true (nobody cares if the user canceled!)
- _____________________________________________________________________*/
-
-
- static Boolean Save (void)
-
- {
- Str255 prompt; /* SFPutFile prompt string */
- Str255 defName; /* default name for help save dlog */
- OSErr rCode; /* result code */
- Str255 rCodeStr; /* result code as a string */
-
- /* Get the prompt string and default file name. */
-
- GetIndString(prompt, rNameStrings, iPromptStr);
- GetIndString(defName, rNameStrings, iDefNameStr);
-
- /* Call hlp_Save to save the file. */
-
- rCode = hlp_Save(prompt, defName, 'MSWD', MenuPick);
-
- /* Handle errors. */
-
- if (rCode) {
- if (rCode == dskFulErr) {
- utl_StopAlert(eDiskFull, nil, 0);
- } else if (rCode == fLckdErr) {
- utl_StopAlert(eFileLocked, nil, 0);
- } else {
- NumToString(rCode, rCodeStr);
- ParamText(rCodeStr, nil, nil, nil);
- utl_StopAlert(eUnexpectedSave, nil, 0);
- };
- };
-
- return true;
- }
-
- /*______________________________________________________________________
-
- PageSetup - Process Page Setup Command.
-
- Exit: function result = error code.
- _____________________________________________________________________*/
-
-
- static OSErr PageSetup (void)
-
- {
- Boolean canceled;
-
- misc_ValPrint(&helpPrint, false);
- helpPrint.menuPick = MenuPick;
- return rpp_StlDlog(&helpPrint, &canceled);
- }
-
- /*______________________________________________________________________
-
- Print - Process Print Command.
-
- Entry: printOne = true if Print One command.
-
- Exit: function result = error code.
- _____________________________________________________________________*/
-
-
- static OSErr Print (Boolean printOne)
-
- {
- Str255 titleTmpl; /* template for date, time, pnum in headers */
- Str255 docName; /* document name */
-
- GetIndString(titleTmpl, rNameStrings, ihlpDocTmpl);
- GetIndString(docName, rNameStrings, ihlpDocTitle);
- helpPrint.title = docName;
- helpPrint.titleTmpl = titleTmpl;
- helpPrint.docName = docName;
- misc_ValPrint(&helpPrint, false);
- helpPrint.menuPick = MenuPick;
- return hlp_Print(&helpPrint, printOne);
- }
-
- /*______________________________________________________________________
-
- Adjust - Adjust Menus.
- _____________________________________________________________________*/
-
-
- static void Adjust (void)
-
- {
- MenuHandle fileM; /* handle to file menu */
- MenuHandle editM; /* handle to edit menu */
-
- fileM = GetMHandle(mFile);
- editM = GetMHandle(mEdit);
- EnableItem(fileM, iClose);
- EnableItem(fileM, iSaveAs);
-
- DisableItem(fileM, iPageSetup);
- DisableItem(fileM, iPrint);
- DisableItem(fileM, iNew);
- DisableItem(fileM, iSave);
- DisableItem(fileM, iOpen);
- DisableItem(fileM, iPrime);
-
- /* printing won't work for now */
-
- DisableItem(editM, 0);
-
- }
-
- /*______________________________________________________________________
-
- DrawTconTitle - Draw Table of Contents Title.
- _____________________________________________________________________*/
-
-
- static void DrawTconTitle ()
-
- {
- Str255 str; /* title */
- short h; /* horizontal coord of title */
- Rect tconRect={25, 386, 267, 483};
-
- GetIndString(str, rNameStrings, iTConTitle);
- TextFace(bold);
- h = (tconRect.left + tconRect.right
- - StringWidth(str)) >> 1;
- MoveTo(h, tconRect.top-5);
- DrawString(str);
- TextFace(normal);
- }
-
- /*______________________________________________________________________
-
- help_Open - Open Help Window.
-
- Entry: tag = Tagged line to jump to, or 0 if none.
- _____________________________________________________________________*/
-
-
- void help_Open (short tag)
-
- {
- hlp_PBlock p; /* hlp_Open param block. */
- short fNum; /* font number */
- /* 288*/
- Rect docRect={10, 12, 328, 374};
- Rect tconRect={25, 386, 267, 483};
-
-
- /* If the window is already open, activate it and jump to the tag. */
-
- if (HelpWindow) {
- SelectWindow(HelpWindow);
- if (tag) hlp_Jump(tag);
- return;
- };
-
- /* Get the help window and restore its state. */
-
- HelpWindow = utl_GetNewWindow(rAboutWin, (Ptr)&HelpWRecord, (WindowPtr)-1);
- SetPort(HelpWindow);
-
- /* Initialize the window object. */
-
- ((WindowPeek)HelpWindow)->refCon = (long)&HelpWindObject;
- HelpWindObject.windKind = helpWind;
- SetRect(&HelpWindObject.sizeRect, HelpWindow->portRect.right,
- 100, HelpWindow->portRect.right, 0x7fff);
- HelpWindObject.update = hlp_Update;
- HelpWindObject.activate = hlp_Activate;
- HelpWindObject.deactivate = hlp_Deactivate;
- HelpWindObject.resume = nil;
- HelpWindObject.suspend = nil;
- HelpWindObject.click = Click;
- HelpWindObject.help = Help;
- HelpWindObject.grow = hlp_Grow;
- HelpWindObject.zoom = hlp_Zoom;
- HelpWindObject.key = hlp_Key;
- HelpWindObject.close = Close;
- HelpWindObject.disk = nil;
- HelpWindObject.save = Save;
- HelpWindObject.pageSetup = PageSetup;
- HelpWindObject.print = Print;
- HelpWindObject.edit = nil;
- HelpWindObject.adjust = Adjust;
- HelpWindObject.periodic = nil;
- HelpWindObject.dialogPre = nil;
- HelpWindObject.dialogPost = nil;
-
- /* Initialize hlp_Open param block. */
-
- if (!utl_GetFontNumber("\pGeneva", &fNum)) fNum = applFont;
- p.scrollLine = 0;
- p.firstStrID = firstDocID;
- p.listDefID = lDefID;
- p.textRect = docRect;
- p.fontNum = fNum;
- p.fontSize = 9;
- p.tabConID = tconID;
- p.tabConRect = tconRect;
- p.tabConFNum = fNum;
- p.tabConFSize = 9;
- p.tabConLSep = 12;
- p.tag = tag;
- p.tagRezID = tagID;
- p.cellRezID = cellID;
- p.cellOption = 2;
- p.extraUpdate = DrawTconTitle;
-
- /* Call hlp_Open to complete the open. */
-
- hlp_Open(HelpWindow, &p);
- }
-
-
-
-